package model.searchers.advancedSearchers.hashTableSearchers;

import java.io.IOException;



import model.searchers.advancedSearchers.hashTableSearchers.StaticHashTable;
import utilityClasses.Timer;




/**
 * Class StaticHashTableSearcher represents a searcher, which can make look ups in a static hash table
 * created from a file. It searches for the URLs on which a given search word occurs, and the number of occurrences on each URL. 
 * It is furthermore possible to put new data in the static hash table. 
 * It is possible to choose page ranking of results and boolan search mode.
 */
public class StaticHashTableSearcher extends GenericHashTableSearcher { 

		private int size;
	/**
	 * Constructor of StaticHashTableSearcher.
	 * 
	 * @param filename	file to create hash table from
	 * @param size		size of hash table
	 * @param mode		boolean search mode
	 * @param ranking	page ranking mode
	 * @throws IOException if reading the file causes trouble
	 */
	public StaticHashTableSearcher(String fileName, int size, boolean mode, boolean ranking) throws IOException {

		super();
		this.size = size;
		Timer.printTime(loadData(fileName));
		super.setBooleanSearch(mode);
		super.setPageRank(ranking);
	}

	@Override
	public long loadData(String fileName) throws IOException {
		super.data = new StaticHashTable(size);
		long time = Timer.startTime();
		super.readFile(fileName);
		long total_time = Timer.getTime(time);
		return total_time;

	}

}
